﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for SQL
/// </summary>
public class SQL
{
	public SQL()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public static string Insert(string tablename, string[] files, string[] values)
    {
        string tmp = "INSERT INTO " + tablename + " (";
        for (int i = 1; i < files.Length; i++)
        {
            if (i < files.Length - 1)
            {
                tmp += files[i] + ",";
            }
            else
            {
                tmp += files[i] + ") VALUES ( ";
            }
        }
        for (int j = 0; j < values.Length - 1; j++)
        {
            tmp += "'"+values[j]+"', ";
        }
        tmp += "'"+values[values.Length-1]+"') ";
        
        return tmp;
    }
    public static string Update(string tablename, string[] files, string[] values)
    {
        string tmp = "UPDATE " + tablename + " SET ";
            for (int i = 1; i < files.Length; i++)
            {
                tmp += files[i] + "='" + values[i] + "',";
            }
            tmp = tmp.Substring(0, tmp.Length - 1);
            tmp += " WHERE id='" + values[0] + "'";
        return tmp;
    }
}
